package demo.spring.ioc;

import demo.spring.ioc.services.PetStoreService;
import demo.spring.ioc.services.SimpleMovieLister;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by lushun.chen on 2017/3/25.
 *
 * @author lushun.chen
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext(new String[]{"services.xml", "daos.xml"});

        PetStoreService service = context.getBean("petStore", PetStoreService.class);
        List<String> list = service.getUsernameList();
        for (String s : list) {
            System.out.println(s);
        }

        SimpleMovieLister lister=context.getBean("simpleMovieLister",SimpleMovieLister.class);
        System.out.println(lister.hashCode());
        SimpleMovieLister lister2=context.getBean("simpleMovieLister",SimpleMovieLister.class);
        System.out.println(lister2.hashCode());
    }
}
